<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>draw.io Viewer</title>
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.7.1/css/aui.css" media="all">
<style type="text/css">
html, body {
	height:100%;
	overflow:hidden;
}
body {
	font-family:Arial,sans-serif;
	width:100%;
	margin:0;
	background-color: #fff;
	background-image:url(/connect/jira/spinner.gif);
	background-repeat:no-repeat;
	background-position:center;
}
.drawio-add-diagram {
	float: right;
	margin-right: 5px;
}
.loading {
	background-color: #fff;
	background-image:url(/connect/jira/spinner.gif);
	background-repeat:no-repeat;
	background-position:center;
}
</style>
</head>
<body>
<script type="text/javascript">
//Parses URL parameters
function getUrlParam(param)
{
	var result = (new RegExp(param + '=([^&]*)')).exec(window.location.search);
	
	if (result != null && result.length > 0)
	{
		return decodeURIComponent(result[1].replace(/\+/g, '%20'))
	}
	
	return null;
};

function getBaseUrl()
{
	var baseUrl = getUrlParam('xdm_e', true) + getUrlParam('cp', true);
	//Ensure baseUrl belongs to attlasian (*.jira.com and *.atlassian.net)
	//Since we add cp to xdm_e, we had to ensure that there is a slash after the domain. Since if xdm_e is ok, cp can corrupt is such as cp = '.fakedomain.com' such that baseUrl is atlassian.net.fakedomain.com
	if (/^https:\/\/([^\.])+\.jira\.com\//.test(baseUrl + '/') || /^https:\/\/([^\.])+\.atlassian\.net\//.test(baseUrl + '/')) 
	{
		return baseUrl;
	}
	throw 'Invalid baseUrl!';
};

function getDocDim()
{
	var body = document.body,
    html = document.documentElement;

	var height = Math.max(body.offsetHeight, html.clientHeight, html.offsetHeight);

	var width = Math.max(body.offsetWidth, html.clientWidth, html.offsetWidth);
	
	return {w: width, h: height};
};
// Sets global environment variables
RESOURCE_BASE = '/resources/dia';
STENCIL_PATH = '/stencils';
SHAPES_PATH = '/shapes';
IMAGE_PATH = '/images';

// Overrides browser language with JIRA user language
var lang = getUrlParam('loc');

// Language is in the Connect URL
if (lang != null)
{
	var dash = lang.indexOf('-');
	
	if (dash >= 0)
	{
		mxLanguage = lang.substring(0, dash);
	}
}
</script>
<script src="/js/viewer.min.js" type="text/javascript"></script>
<script src="../new_common/cac.js" type="text/javascript"></script>
<script src="../onedrive_common/ac.js" type="text/javascript"></script>
<script src="../gdrive_common/gac.js" type="text/javascript"></script>
<script src="viewerPanel.js" type="text/javascript"></script>
<script type="text/javascript">
// Logs uncaught errors
EditorUi.enableLogging = true;

window.onerror = function(message, url, linenumber, colno, err)
{
	message = 'Jira Cloud: ' + ((message != null) ? message : '');
	
	EditorUi.logError(message, url, linenumber, colno, err);
};
</script>
</body>
</html>
